<template>
  <div class="driver-management-page">
    <div class="search-wrapper">
      <super-search :search-form="searchForm" :search-item-config="searchItemList" @search="searchHandle"></super-search>
    </div>
    <div class="content-wrapper">
      <super-table
        :height="tableHeight"
        ref="tableRef"
        v-model:page="searchForm.pageNum"
        v-model:limit="searchForm.pageSize"
        :loading="loading"
        :data="tableData"
        :total="searchForm.total"
        :column="tableColumn"
        @change-page="getData"
      >
        <template #bizDriverAreaInfoResDtoList="{ row }">
          <a-button type="link" @click="showAreaHandle(row)">查看</a-button>
        </template>
        <template #haveArea="{ row }">
          <a-tag v-if="row.haveArea === 1" color="#87d068"> 已分配 </a-tag>
          <a-tag v-if="row.haveArea === 0" color="#cd201f"> 未分配 </a-tag>
        </template>
        <template #status="{ row }">
          <a-tag v-if="row.status === 1" color="#87d068"> 启用 </a-tag>
          <a-tag v-if="row.status === 0" color="#cd201f"> 停用 </a-tag>
        </template>
        <template #action="{ row }">
          <a-button type="link" @click="distributionAreaHandle(row)">分配区域</a-button>
        </template>
      </super-table>
    </div>
    <a-modal v-model:visible="dialogOpts.visible" :maskClosable="false" :keyboard="false" :closable="true" :footer="null" :title="dialogOpts.title" :width="dialogOpts.width">
      <component v-model:visible="dialogOpts.visible" :is="dialogOpts.component" :type="dialogOpts.type" :pass-data="dialogOpts.passData" @submit="dialogSubmitHandle"></component>
    </a-modal>
    <!-- 抽屉 -->
    <a-drawer v-model:visible="drawerOpts.visible" :title="drawerOpts.title" :maskClosable="false" :closable="true" :width="drawerOpts.width" placement="right">
      <component v-model:visible="drawerOpts.visible" :is="drawerOpts.component" :type="drawerOpts.type" :pass-data="drawerOpts.passData" @submit="drawerSubmitHandle"></component>
    </a-drawer>
  </div>
</template>
<script lang="ts">
import DistributionArea from "./components/distributionArea/index.vue";
import ReceivingArea from "./components/receivingArea/index.vue";
export default {
  name: "DriverManagement",
  components: {
    DistributionArea,
    ReceivingArea
  }
};
</script>
<script lang="ts" setup>
import ModalHook from "@/hook/modalHook";
import TableHeightHook from "@/hook/tableHeightHook";
import { searchItemList, tableColumn } from "./data";
import InitHook from "./composables/initHook";
import OperationHook from "./composables/operationHook";
const { tableHeight, loading } = TableHeightHook(15);
const { searchForm, tableData, dialogOpts, drawerOpts } = InitHook();
const { searchHandle, getData, distributionAreaHandle, showAreaHandle } = OperationHook({ searchForm, tableData, loading, dialogOpts, drawerOpts });
const { dialogSubmitHandle, drawerSubmitHandle } = ModalHook({
  dialogOpts,
  drawerOpts,
  callBack: getData
});
searchHandle();
</script>
<style lang="stylus" scoped></style>
